package com.i.template.aspect;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * @author lewis
 * @type class
 * @description
 * @since 2024/8/9
 */
@Component
@Aspect
public class AccessCountAspect {
    private static final AtomicInteger COUNTER = new AtomicInteger();
    @Pointcut("execution(* com.i.template.controller.*.*(..))")
    public void pointCut() {}
    @Before("pointCut()")
    public void addAccessCount(JoinPoint point) {
        COUNTER.incrementAndGet();
    }
    public static int getAccessCount() {
        return COUNTER.get();
    }
}
